var bar_002 = echarts.init(document.getElementById('bar-002'));
bar_002.setOption({
    color: ['#3398DB'],
    tooltip: {
        trigger: 'axis',
        // axisPointer: {            // 坐标轴指示器，坐标轴触发有效
        //     type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        // },
        formatter(params){
            for(x in params) {
                return params[x].name+ '<br/>'+params[x].seriesName+"："+params[x].value+'<br/>'+"项目金额："+params[x].data.budget;
            }
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            data: [],
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    yAxis: [
        {
            type: 'value'
        }
    ],
    series: [
        {
            name: '项目数量',
            type: 'bar',
            barWidth: '60%',
            data: []
        }
    ]
});

commonBar1();

function searchBar1() {
    var sdate = $('#sdateBar1').val();
    var edate = $('#edateBar1').val();
    var param = {sdate:sdate, edate:edate}
    commonBar1(param);
}

function commonBar1(param = null){
    var date=new Date;
    var y = date.getFullYear()
    $('#sdateBar1').val(y+'-01-01');

    $.get('./index.php?a=totalCompany&m=report|main&d=report', param).done(function (data) {
        data = JSON.parse(data)
        bar_002.setOption({
            xAxis: {
                data: data.name,
            },
            series: [{
                data:data.data,
            }]
        });
    });
}

bar_002.on('click', function (params) {
    let sdate = $('#sdateBar1').val();
    let edate = $('#edateBar1').val();
    console.log(sdate,edate);
    let urls = 'report,main,list,comid='+params.data.comid+',sdate='+sdate+',edate='+edate;
    addtabs({num:'num329',url:urls,icons:'',name:'采购项目执行汇总'});
});
